from collections import defaultdict, deque

n = int(input())
edges = defaultdict(set)
in_degree = [[0, i] for i in range(n + 1)]  # 入度
for _ in range(n):
    u, v = map(int, input().split())
    edges[u].add(v)
    edges[v].add(u)
    in_degree[u][0] += 1
    in_degree[v][0] += 1

queue = deque([node for node in range(1, n + 1) if in_degree[node][0] == 1])
while queue:
    cur = queue.popleft()
    for neighbor in edges[cur]:
        in_degree[neighbor][0] -= 1
        if in_degree[neighbor][0] == 1:
            queue.append(neighbor)
ans = [x[1] for x in in_degree if x[0] > 1]
ans.sort()
print(" ".join(map(str, ans)))
